<?php
class Admin_Form_UserAdd extends Apps_Form {
	public function init() {
		$username = new Zend_Form_Element_Text('username',
					array(
						'label'			=> 'User name',
						'required'		=> true,
						'filters'		=> array('StringTrim'),
						'validators'	=> array(new Zend_Validate_Db_NoRecordExists(
												array(
														'table'	=>	'user',
														'field'	=>	'username'
												)))
						)
				);

		$password = new Zend_Form_Element_Password('password',
					array(
						'label'			=> 'Password',
						'required'		=> true,
						'required'		=> true,
						'filters'		=> array('StringTrim')
						)
				);
		$passwordConfirm = new Zend_Form_Element_Password('passwordConfirm',
					array(
						'label'			=> 'Password again',
						'required'		=> true,
						'required'		=> true,
						'filters'		=> array('StringTrim'),
						'validators' 	=> array(array('identical', true, array('password')))
					)
				);

		$group = new Zend_Form_Element_Select('user_group_id',
				array(
						'label'			=>	'User group',
						'required'		=>	true,
						'multiOptions'	=>	Model_Tool_DataMapper::getInstance()->mapKeyValue(new Model_DbTable_UserGroup(),'id','name')
				)
		);

		$fullName = new Zend_Form_Element_Text('full_name',
				array(
						'label'			=> 'Full name',
						'filters'		=> array('StringTrim')
				)
		);

		$email = new Zend_Form_Element_Text('email',
					array(
						'label'			=>	'Email',
						'validators'	=>	array('EmailAddress'),
						'filters'		=>	array('StringTrim')
						)
				);

		$phone = new Zend_Form_Element_Text('phone',
					array(
						'label'			=>	'Phone',
						'filters'		=>	array('StringTrim')
						)
				);

		$address = new Zend_Form_Element_Textarea('address',
					array(
						'label'			=>	'Address',
						'filters'		=>	array('StringTrim')
						)
				);

		$description = new Zend_Form_Element_Textarea('description',
					array(
						'label'			=>	'Description',
						'filters'		=>	array('StringTrim')
						)
				);

		$this->setLegend('Add New');
		$this->addElements(
				array(
						$username,
						$password,
						$passwordConfirm,
						$group,
						$fullName,
						$email,
						$phone,
						$address,
						$description
						)
				);
		$this->addActionGroup();
		$this->makeup();
	}
}
